<!DOCTYPE html>
<html>
<meta charset="utf-8">
<title>科鹏机电</title>
<head th:include="include :: header"></head>
<link href="/css/layui.css" rel="stylesheet">
<body>
<input type="hidden" id="id" name="id" th:value="${id}">
<div class="layui-tab"  lay-filter="test1">
	<ul class="layui-tab-title">
		<li class="layui-this" lay-id="111">基本信息</li>
		<li lay-id="222">项目文件</li>
		<li lay-id="333">修改记录</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show">
			<iframe class='layui-col-xs12' th:src="${firstsrc}"></iframe>
		</div>
		<div class="layui-tab-item"><iframe class='layui-col-xs12' src="#"></iframe></div>
		<div class="layui-tab-item"><iframe class='layui-col-xs12' src="#"></iframe></div>
	</div>
</div>

<div th:include="include::footer"></div>
<script src="/js/layui.js"></script>
<script>
	var id = $("#id").val();
	layui.use(['element','jquery'], function() {
		var element = layui.element;
		var $ = jQuery = layui.jquery;
		FrameWH();
		//获取hash来切换选项卡，假设当前地址的hash为lay-id对应的值
		var layid = location.hash.replace(/^#test1=/, '');
		element.tabChange('test1', layid); //假设当前地址为：http://a.com#test1=222，那么选项卡会自动切换到“发送消息”这一项
		//监听Tab切换，以改变地址hash值
		element.on('tab(test1)', function(){
			location.hash = 'test1='+ this.getAttribute('lay-id');
			console.log(location.hash);
			if(this.getAttribute('lay-id') == "111"){
				// var src=$(".layui-tab-item.layui-show").find("iframe").attr("src");
				$(".layui-tab-item.layui-show").find("iframe").attr("src","/itm/project/ckedit/"+id);
			}else if(this.getAttribute('lay-id') == "222"){
				// var src=$(".layui-tab-item.layui-show").find("iframe").attr("src");
				$(".layui-tab-item.layui-show").find("iframe").attr("src","/itm/project/getFiles/"+id);
			}else if(this.getAttribute('lay-id') == "333"){
				// var src=$(".layui-tab-item.layui-show").find("iframe").attr("src");
				$(".layui-tab-item.layui-show").find("iframe").attr("src","/itm/projectLog/listbyitminfo/"+id);
			}
		});
		function FrameWH() {
			var h = $(window).height()-100;
			$("iframe").css("height",h+"px");
		}

		$(window).resize(function () {
			FrameWH();
		});
	});
</script>
</body>
</html>
